﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace WorkItemVisualization
{
    internal static class XmlTextWriterExtension
    {
        /// <summary>
        /// Writes the attribute if the value is not null or empty.
        /// 
        /// If empty it doesn't do anything.
        /// 
        /// Semantically equivalente of doing
        /// 
        /// if (value != "")xtw.WriteAttributeString(attribute,value);
        /// </summary>
        /// <param name="xmlTextWriter"></param>
        /// <param name="attribute"></param>
        /// <param name="value"></param>
        public static void WriteAttributeStringIfNotEmpty(this XmlTextWriter xmlTextWriter,string attribute,string value)
        {
            if (String.IsNullOrEmpty(value) == false)
                xmlTextWriter.WriteAttributeString(attribute, value);
        }
    }
}
